#!/bin/bash
#语法
# for variable in list
# do
#     代码块
# done 

#Ex1
# for  i in  1 2 3 4 5 6 
# do 
#     echo "第${i}次输出的${i}"
# done 

# for  command  in df  ip  
# do
#     sleep  30  #睡眠
#     echo  "$command"
# done

# ip_sub="192.168.0"

# for i in  {1..254}
# do
#     ping   -c 3 $ip_sub.$i
# done

username="root"
password="abc123"
for  i in  1 2 3
do
    read  -p "输入用户名:" user
    read  -t 30 -s -p "输入密码:" pass
    if  [ $username  == $user  -a $password  == $pass ];then
        echo " "
        echo -e "\n登录系统成功"
    else
        echo " "
        echo "登录失败，请检查用户名或者密码是否输入错误"
    fi
    a=`echo "3-$i"| bc`
    # a=`echo "3-$i"| expr`
    echo  "剩余${a}数"
done
